#include <config.h>
#ifdef LANG_X86

;
; Gdt.s -- contains global descriptor table and interrupt descriptor table
;          setup code.
;

global gdtFlush     ; Allows the C code to link to this

gdtFlush:
    mov eax, [esp+4]  ; Get the pointer to the GDT, passed as a parameter.
    lgdt [eax]        ; Load the new GDT pointer

    mov ax, 0x10      ; 0x10 is the offset in the GDT to our data segment
    mov ds, ax        ; Load all data segment selectors
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov ss, ax
    jmp 0x08:flush2   ; 0x08 is the offset to our code segment: Far jump!
flush2:
    ret

global idtFlush

idtFlush:
    mov eax, [esp+4]
    lidt [eax]
    ret

global tssFlush
tssFlush:
    mov ax, 0x2B
    ltr ax
    ret

#endif // LANG_X86
